package adke.gui.panels;

import info.clearthought.layout.TableLayout;
import java.awt.Component;
import javax.swing.JComponent;
import javax.swing.JPanel;

// ik ben hier trouwens vet trots op

public class MarginPanel extends JPanel
{
    private TableLayout layout;
    
    public MarginPanel(JComponent component, int xmargin, int ymargin)
    {
        this();
        
        setMargins(xmargin, ymargin);
        
        add(component, "1, 1");
    }
    
    public MarginPanel()
    {
        double[][] size = { {0, TableLayout.FILL, 0}, {0, TableLayout.FILL, 0} };
        layout = new TableLayout(size);
        setLayout(layout);
    }
    
    public void setMargins(int xmargin, int ymargin)
    {
        layout.setColumn(new double[]{xmargin, TableLayout.FILL, xmargin});
        layout.setRow(new double[]{ymargin, TableLayout.FILL, ymargin});
    }
    
    public Component add(Component component)
    {
        super.add(component, "1, 1");
        return component;
    }
    
    public void add(Component component, int xmargin, int ymargin)
    {
        add(component);
        setMargins(xmargin, ymargin);
    }
}
